#coding=utf-8
import platform_login_api
import datetime
import threading
from time import ctime,sleep
import requests

def game(func):
    headers = platform_login_api.login('18300001004')[0]
    for i in range(50):
        starttime = datetime.datetime.now()
        s = requests.session()
        # 开始抽奖
        start = s.get('http://community-platform-api-test.gdgyun.com/api/community/activity/1/lottery/start',headers=headers)
        print start.text
        endtime = datetime.datetime.now()
        print "round:%s, tread number:%s, returnValue:%s,time:%f" % (i, func, s, (endtime - starttime).microseconds / 1000)


if __name__ == '__main__':
    threads = []
    for i in range(50):
        name = "t%s" % (i)
        name = threading.Thread(target=game, args=(i,))
        threads.append(name)

    for t in threads:
        t.setDaemon(True)
        t.start()
    t.join()

